﻿using JetBrains.Annotations;
using MyLifeVn.AddThis.Models;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;

namespace MyLifeVn.AddThis.Drivers
{
    [UsedImplicitly]
    public class AddThisSettingsPartDriver : ContentPartDriver<AddThisSettingsPart>
    {
        protected override string Prefix
        {
            get { return "AddThis"; }
        }

        protected override DriverResult Editor(AddThisSettingsPart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_AddThis_Settings",
                                () => shapeHelper.EditorTemplate(TemplateName: "Parts.AddThis.Settings", Model: part, Prefix: Prefix));
        }

        protected override DriverResult Editor(AddThisSettingsPart part, IUpdateModel updater, dynamic shapeHelper)
        {
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}